#pragma once
#ifndef PropertyContent_H
#define PropertyContent_H

#include "FileAccess.h"

namespace ParticleEngine
{
	class PropertyContent
	{
	public:
		PropertyContent(float NewConduct)
		{
			Conduct = NewConduct;
			Volume = 0.f;
			ContentAdjust = 0.f;
		}

		inline void Sole()
		{
			this->Volume += this->ContentAdjust;
			this->ContentAdjust = 0.f;
		}

		inline void Interaction(PropertyContent*const Other)
		{
			if (!Other) return;

			const float AverageContentConduct = (this->Conduct + Other->Conduct);
			const float Diff = (this->Volume - Other->Volume) * 0.07f * AverageContentConduct;

			this->ContentAdjust = this->ContentAdjust - Diff;
			Other->ContentAdjust = Other->ContentAdjust + Diff;
		}


		void Save(std::ofstream& Strm)
		{
			FileAccess::WriteByRef(Strm, Conduct);
			FileAccess::WriteByRef(Strm, Volume);
			FileAccess::WriteByRef(Strm, ContentAdjust);
		}

		void Load(std::ifstream& Strm)
		{
			FileAccess::ReadByRef(Strm, Conduct);
			FileAccess::ReadByRef(Strm, Volume);
			FileAccess::ReadByRef(Strm, ContentAdjust);
		}

		float Conduct;
		float Volume;
		float ContentAdjust;
	};
}
#endif
